<?php
require_once('functions.php');
require_once('epiOAuth/SimpleTwitter.php');

$userinfo = $session->userinfo;

if($userkeys = is_integrated_with("twitter", $userinfo['id'])) {

	$Twit = new SimpleTwitter($twitterConsumerKey, $twitterConsumerSecret, $userkeys['usertoken'], $userkeys['usersecret']);
	
	echo '<div class = "box feedbox margin">
	  <table>
	  <tr>
      <td><a href = "http://twitter.com/'. $userkeys['username']. '"><img src = "layout/twitter_icon.png" /></a></td>
      <td><a href = "http://twitter.com/'. $userkeys['username']. '"><h3>Twitter</h3></a></td>
	  </tr>';
	
	echo '<tr> 
	<td class="title"><img src="'.$_SESSION['twitterPic'].'" /> '.$userkeys['username'].'\'s recent tweets</td>
	</tr>';

	$tweets = $Twit->getRecentTweets();

	foreach($tweets as $tweet) {
		echo "<tr><td class='status'><b>{$tweet->text}</b><br />"
			."<span class='title updated'><i>Posted {$tweet->postedOn}</i></span></td></tr>";
	}
	echo '</table><div class = "clear"></div></div>';
}

?>